package com.yict.csms.system.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.yict.common.dao.impl.CommonDao;
import com.yict.csms.system.entity.Permission;
import com.yict.csms.system.entity.UserGroupPermission;


/**
 * 
 * 
 * @author Patrick.Deng
 * 
 */
@Repository
public class PermissionDaoImpl extends CommonDao<Permission, Long> {

	public List<UserGroupPermission> getCruPermission(Long userGroupId) {
		List<UserGroupPermission> list = new ArrayList<UserGroupPermission>();
		String queryString = "from UserGroupPermission u where u.userGroup.userGroupId =:userGroupId order by u.createDate desc";
		try {
			Query query = this.getSession().createQuery(queryString);
			query.setLong("userGroupId", userGroupId);
			list = query.list();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}
}
